#!/usr/bin/env bash

COMMIT_SHA="${1:?'Missing required parameter: COMMIT_SHA'}"
GIT_REPO="${2:?'Missing required parameter: GIT_REPO'}"
TEST_IMAGE_NAME="${3:?'Missing required parameter: TEST_IMAGE_NAME'}"

# Optional - only used for print_colorized
source anchore-ci/utils

print_colorized INFO "Building Anchore CLI image '${TEST_IMAGE_NAME}'."; echo

docker build --target base-builder -t "${GIT_REPO}":builder -f ./Dockerfile .
docker build --build-arg CLI_COMMIT="${COMMIT_SHA}" -t "${TEST_IMAGE_NAME}" -f ./Dockerfile .

print_colorized INFO "Successfully built Anchore CLI image '${TEST_IMAGE_NAME}'."; echo
